]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
loginDialog: Don't assume this._user is always defined
authorAlessandro Bono <alessandro.bono369@gmail.com>
Mon, 19 Aug 2024 16:08:42 +0000 (18:08 +0200)
committerAlessandro Bono <alessandro.bono369@gmail.com>
Tue, 20 Aug 2024 10:38:41 +0000 (12:38 +0200)
There are cases where this._user might be null when a session
is opened. This is because the user is not selected via GDM but
it is set through PAM. This happens when logging with smart card
or with credential managers, for example.

Given the session-id of the opened session, look for the owner.
This fixes the following error:
```
gnome-shell[153293]: TypeError: this._user is null

                     Stack trace:
                     _findConflictingSession@resource:///org/gnome/shell/gdm/loginDialog.js:1219:26
                     _onSessionOpened@resource:///org/gnome/shell/gdm/loginDialog.js:1254:51
                     @resource:///org/gnome/shell/ui/init.js:21:20
```

Fixes: df84854d9 ("loginDialog: On login, allow logout a conflicting session")
Closes: https://gitlab.gnome.org/GNOME/gnome-shell/-/issues/7526
Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/3448>

js/gdm/loginDialog.js

index 9e1c050f806daf25a36c6c9459563ef1c4fccfc8..e82313d9ecfee6b35c4f7eeb71c4b63c4ff4ac70 100644 (file)
@@ -1137,15 +1137,15 @@ export const LoginDialog = GObject.registerClass({
         });
     }
 
-    async _findConflictingSession(ignoreSessionId) {
-        const userName = this._user.get_user_name();
+    async _findConflictingSession(startingSessionId) {
         const loginManager = LoginManager.getLoginManager();
         const sessions = await loginManager.listSessions();
+        const [, , startingSessionOwner, ,] = sessions.find(([id, , , ,]) => id === startingSessionId);
         for (const session of sessions.map(([id, , user, , path]) => ({id, user, path}))) {
-            if (ignoreSessionId === session.id)
+            if (startingSessionId === session.id)
                 continue;
 
-            if (userName !== session.user)
+            if (startingSessionOwner !== session.user)
                 continue;
 
             const sessionProxy = loginManager.getSession(session.path);